package com.kyle.pagingdemo

import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 * author: liliang
 * date: 1/26/21 10:15 PM
 * desc:
 */
class ViewPager3DTransform: ViewPager2.PageTransformer {

    override fun transformPage(page: View, position: Float) {
        //效果1
//        page.scaleX = 1 - abs(position)
//        page.scaleY = 1 - abs(position)

//        page.scaleX = 0.9f.coerceAtLeast(1 - abs(position))
//        page.scaleY = 0.9f.coerceAtLeast(1 - abs(position))

        page.pivotX = if (position < 0f) page.width.toFloat() else 0f //左边页面：0~-1；右边的页面：1~0
        page.pivotY = page.height * 0.5f
        page.rotationY = position * 45f //0~90度


    }
}